package gui.edit.components;

import gui.edit.enums.E_EditParamsSliders;
import gui.edit.utils.QualitativeSliders;

import java.util.Hashtable;

import javax.swing.BorderFactory;
import javax.swing.JLabel;

import tuio.components.SliderTouch;

import controls.edit.ParamControl;

import data.Constants;

/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class ParamsSliders_DynamicityPanel extends A_ParamsSliders_panel implements I_ParamsSliders_panel{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7882648363785151248L;

	public ParamsSliders_DynamicityPanel(SliderTouch slider, ParamControl paramControl,E_EditParamsSliders editParam){
		super(slider, editParam, paramControl);
	}

	@Override
	public void customizeSlider() {
		//table des labels
        Hashtable<Integer, JLabel> labelTable = QualitativeSliders.getLabelTable(editParam);
        
        slider.setLabelTable(labelTable);
        slider.setInverted(true);
        
		int sliderValue = slider.getValue();
		String sliderValueString;
		if(labelTable!=null && labelTable.get(sliderValue)!=null){
			sliderValueString = labelTable.get(sliderValue).getText();
			if(sliderValueString.length()>Constants.CAMERA_PANEL_NB_LETTERS_FOR_SLIDERS_LABEL_TABLE){
				sliderValueString=sliderValueString.substring("<htlm><center>".length(),Constants.CAMERA_PANEL_NB_LETTERS_FOR_SLIDERS_LABEL_TABLE+"<html><center>".length());
			}
			field.setText(sliderValueString);
			field.setForeground(labelTable.get(sliderValue).getForeground());
			field.setBorder(BorderFactory.createLineBorder(field.getForeground()));
		}
	}
}
